\ProvidesClass{ttextemp}[2023/09/11 Simple LaTeX Class Template]

% 基于 article 类，您也可以选择其他基类
% \LoadClass{article}  % 英文
\LoadClass[14pt, a4paper, openany, linespread=1.3]{ctexbook}  % 中文

% % 导入宏包
% \RequirePackage[T1]{fontenc}
% \RequirePackage{graphicx}
% \RequirePackage{geometry}
% \RequirePackage{lipsum} 
% \RequirePackage{titlesec}
% \RequirePackage{color}

% % 页面边距设置

% % 自定义颜色
% \definecolor{sectioncolor}{RGB}{50, 50, 250}
% % 自定义标题格式
% \titleformat{\section}
% {\color{sectioncolor}\large\bfseries}
% {\color{sectioncolor}\thesection}{1em}{}

% \titleformat{\subsection}
% {\color{sectioncolor}\normalsize\bfseries}
% {\color{sectioncolor}\thesubsection}{1em}{}

% % 自定义命令
% \newcommand{\important}[1]{\textbf{\color{red}#1}}

% \usepackage{biblatex}
% \addbibresource[location=local]{reference.bib}
% \endinput


\RequirePackage{amsmath, amsthm, amssymb, graphicx, ulem}
\RequirePackage{tikz}
\RequirePackage{calc}
\RequirePackage{geometry}

% \usepackage{newtxtext,newtxmath}    % Times
% \usepackage{newpxtext,mathpazo}   % Pazo
\usepackage{fouriernc}            % Fourier
% \usepackage{mathdesign}
% \usepackage{cmbright}
% \usepackage{eulerpx}

\usepackage{xeCJK}
\setCJKmainfont[]{方正新书宋简体}
\catcode`\。=\active
\newcommand{。}{\ifmmode\text{．}\else ．\fi}

\newcommand{\textbb}[1]{\textbf{\heiti #1}}

% \RequirePackage{extsizes}
% \usepackage{bm}
% \setmainfont{TIMES.TTF}
% 在导言区里的注释
% \newtheorem{example}{例}[section]
% \newtheorem{practice}{练习}[section]
% \setlength{\lineskip}{\baselineskip-\ccwd}
% \setlength{\lineskiplimit}{2.5pt}
\geometry{left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm}
% \geometry{scale=0.775}

\usepackage{scrextend}
\changefontsizes[14pt]{14pt}

\usepackage{setspace}
\doublespacing

% 定义颜色
\definecolor{winered}{rgb}{0.5,0,0}
\definecolor{structurecolor}{RGB}{122,122,142}
\definecolor{main}{HTML}{000000}
\definecolor{second}{HTML}{000000}
\definecolor{third}{HTML}{000000}

% 定义引用的颜色
\usepackage{hyperref}
\hypersetup{colorlinks = true, linktoc=all, linkcolor=black, urlcolor=winered}

% ------------------------------------------------------------%
% 定义定理环境
% \usepackage{amsthm}
\newtheoremstyle{defstyle}{3pt}{3pt}{\kaishu}{-3pt}{\bfseries\color{structurecolor}}{}{0.5em}{\indent ［\thmname{#1} \thmnumber{#2}］ \thmnote{(#3)}}
\newtheoremstyle{thmstyle}{3pt}{3pt}{\kaishu}{-3pt}{\bfseries\color{structurecolor}}{}{0.5em}{\indent［\thmname{#1} \thmnumber{#2}］ \thmnote{(#3)}}
\newtheoremstyle{prostyle}{3pt}{3pt}{\kaishu}{-3pt}{\bfseries\color{structurecolor}}{}{0.5em}{\indent［\thmname{#1} \thmnumber{#2}］ \thmnote{(#3)}}

\theoremstyle{thmstyle} %theorem style
  \newtheorem{theorem}{定理}[section]
\theoremstyle{defstyle} % definition style
  \newtheorem{definition}{定义}[section]
  \newtheorem{lemma}[theorem]{引理}
  \newtheorem{corollary}[theorem]{推论}
\theoremstyle{prostyle} % proposition style
  \newtheorem{proposition}[theorem]{命题}
  \newtheorem{example}[theorem]{例题}
  \newtheorem{remark}{注}[section]

\renewenvironment{proof}[1][证明]{\par{\textbf{#1.}} \;\fangsong}{\qed\par}
\newenvironment{solution}{\par{\textbf{解.}} \;\kaishu}{\qed\par}
\newcommand{\intro}[1]{\rightline{\parbox[t]{5cm}{\footnotesize \fangsong\quad\quad #1 }}}
% ------------------------------------------------------------%

\newenvironment{introduction}{
  \begin{quotation}
    \fangsong  
}{
  \vspace*{1pt}
  \end{quotation}
}

% 设置章形式
\usepackage{titlesec, titletoc}
\linespread{1.4} 	

\usepackage{fancyhdr}
\fancyhf{}
\renewcommand{\headrule}{\color{structurecolor}\hrule width\textwidth}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{1pt}
\fancypagestyle{plain}{\renewcommand{\headrulewidth}{0pt}\fancyhf{}\renewcommand{\headrule}{}}

\fancyhead[c]{\color{structurecolor}\kaishu\rightmark}
\fancyfoot[c]{\color{structurecolor}\small\thepage}

\titleformat{\chapter}[display]{\Large}
{\color{structurecolor}\filright \parbox{1cm}{\vbox to 1.5cm{\vfill\hbox to 4cm{\hfill\Huge \bfseries \color{structurecolor}{Chapter} \thechapter \hfill}}}}
{-2ex}
{\color{structurecolor} \huge\bfseries \filright \vspace*{1em}}
[\vspace*{5pt} {\titlerule[2pt]}]


\titleformat{\section}[frame]{\normalfont\color{main}}{\footnotesize \enspace \large \textcolor{main}{\S \,\thesection}\enspace}{14pt}{\Large\filcenter \bf \kaishu }


\titleformat{\subsection}[hang]{\bfseries}{\large\bfseries\color{main}\thesubsection\enspace}{1pt}{\color{main}\large\bfseries\filright}

\titleformat{\subsubsection}[hang]{\bfseries}{\large\bfseries\color{main}\thesubsubsection\enspace}{1pt}{\color{main}\large\bfseries\filright}
% ------------------------------------------------------------%

% 设置封面
\usepackage{titling}
\renewcommand*{\maketitle}{
    \begin{titlepage}
        \newgeometry{margin = 0in}
        \parindent=0pt
        \includegraphics[width=\linewidth]{cover.png}
        \vfill
        \begin{center}
            \parbox{0.618\textwidth}{
            \hfill {\bfseries \Huge \thetitle} \\[0.6pt]  
            \rule{0.618\textwidth}{4pt} \\ 
        }
        \end{center}
        % \vfill
        \begin{center}
            \parbox{0.618\textwidth}{
                \hfill\Large
                \kaishu 
                \begin{tabular}{r|}
                作者：\theauthor \\ 
                时间：\thedate \\
                \end{tabular}
            }
        \end{center}
        \vfill
        \begin{center}
            \parbox[t]{0.7\textwidth}{\centering \kaishu }
        \end{center}
        \vfill
    \end{titlepage}
    \restoregeometry
    \thispagestyle{empty}
}
% ------------------------------------------------------------%